class Person3 {
  constructor(
    protected name: string,
    protected age: number
  ) { }
  protected getDetails() {
    console.log(`${this.name}今年${this.age}岁`)
  }
  introduce(){
    /**
     * 内部可以访问 - protected
     */
    console.log(this.getDetails())
  }
}

const p2 = new Person3('jack',12)
p2.introduce() //public
/**
 * 外部无法访问 - protected
 */
// p2.name //error
// p2.age //error
// p2.getDetails() //error



class Student3 extends Person3 {
  study(){
    /**
     * 子类可以访问 - protected
     */
    this.getDetails()
    console.log(`${this.name}`)
  }
}
